package com.zyh.scs.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zyh.scs.admin.service.UserCompanyService;
import com.zyh.scs.common.core.util.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hwh
 * @ClassName: 公司接口$
 * @Description: $
 * @Date $
 * @Version 1.0
 */
@RestController
@AllArgsConstructor
@RequestMapping("/company")
@Tag(description = "company", name = "公司管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class UserCompanyController {

    private final UserCompanyService userCompanyService;

    /**
     * 分页查询公司信息
     *
     * @param page 分页对象
     * @return
     */
    @GetMapping("/getCompanyPage")
    @PreAuthorize("@pms.hasPermission('scsx_company_view')")
    @Operation(summary = "分页查询公司信息", description = "分页查询公司信息")
    public R getDeductionPage(@ParameterObject Page page) {
        return R.ok(userCompanyService.getCompanyPage(page));
    }

    /**
     * 通过公司id查询公司信息
     *
     * @param companyId ID
     * @return 用户信息
     */
    @GetMapping("/company")
    @Operation(summary = "通过公司id查询公司信息", description = "通过公司id查询公司信息")
    @PreAuthorize("@pms.hasPermission('scsx_company_view')")
    public R company(Long companyId) {
        return R.ok(userCompanyService.getCompanyById(companyId));
    }


}
